// ==UserScript==
// @name            TW - FSBeta
// @namespace       http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/test/TW-full-screen.user.js
// @description     Zmiana wygląu TW. wersja 0.0.1 beta
// @author          Dariusz Szyndler (Darius II)
// @website         http://pl-the-west.googlecode.com/
// @include         http://*.the-west.*/game.php*
// @include         http://*.the-west.*/forum.php*
// @history         0.0.1 beta - start projektu
// ==/UserScript==

var version = "0.0.1 beta";

try {
//	ScriptUpdater.check(101628, version);
} catch(e) { };

// ustawienia wstępne
var enable_weststats = false;  // nie działa
var enable_westinsider = false; // nie działa
var enable_westcalc = false; // nie działa
var enable_fortsmaps = true; // true/false
var enable_westforts = false; // nie działa
var enable_motivation_duel = false; //
var enable_forum = false;  // nie działa
var base_img = "http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/";

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) {return;}
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}


addGlobalStyle('body {padding:0; width:100%; height:100%; overflow-x:hidden;}');
addGlobalStyle('#minimap_container { top:0px!important; }');
addGlobalStyle('#head_container { background:url("../images/main/borders_top.png") repeat-x scroll 0 11px transparent');
addGlobalStyle('#main_sizer { padding-top:40px; }');
addGlobalStyle('#head_background, #workbar_left, .workbar_top, #workbar_right { background:transparent; height:auto; }');
addGlobalStyle('#head_background { margin-left:0px; margin-right:0px; }');
addGlobalStyle('#character_money { margin-right:15px;}');
addGlobalStyle('#avatar { left:15px; }');
addGlobalStyle('#avatar_picture, #avatar_picture_click { left:17px; }');
addGlobalStyle('#health_bar, #energy_bar, #experience_bar { left:107px; }');
addGlobalStyle('#level_box { left:37px; }');
addGlobalStyle('#character_name { left:91px; }');
addGlobalStyle('#left_menu .menu_list, #right_menu .menu_list { margin-top:0px; }');
addGlobalStyle('#left_menu, #right_menu { height:auto; }');
addGlobalStyle('#left_menu { left:-120px; }');
addGlobalStyle('#right_menu { right:-120px; clip:rect(auto, 25px, auto, auto) }');
addGlobalStyle('#current_task_box { top:32px; width:350px; background: url("'+base_img+'current_task_text.png") no-repeat scroll 0 0 transparent; margin-left:-175px; z-index:1001; }');
addGlobalStyle('#current_task_box_bottom { width:350px; background: url("'+base_img+'current_task_text.png") no-repeat scroll bottom 100% transparent;}');
addGlobalStyle('#workbar_left { padding-top:0px; margin-top:0px; left:30px; }');
addGlobalStyle('#workbar_right { padding-top:0px; margin-top:0px; right:140px; }');
addGlobalStyle('.wb_taskbar { top:125px; height:75px; width:auto; }');
addGlobalStyle('#wb_task_0, #wb_task_1, #wb_task_2, #wb_task_3, #wb_task_4, #wb_task_5, #wb_task_6, #wb_task_7 { float:left; opacity:0.5; filter:alpha(opacity=50); background:url(http://i757.photobucket.com/albums/xx211/Darius_II/tw/workbar_item_background.png) no-repeat 0px 32px; }');
addGlobalStyle('#wb_task_0, #wb_task_1, #wb_task_2, #wb_task_3 { margin-left:0px; }');
addGlobalStyle('#wb_task_4, #wb_task_5, #wb_task_6, #wb_task_7 { margin-right:0px; }');
addGlobalStyle('#main_container_border_left { left:10px; }');
addGlobalStyle('#main_container_border_right { right:10px; }');
addGlobalStyle('#main_container { margin-left:10px; margin-right:10px; }');
addGlobalStyle('#current_task_box_text a { color: yellow; ');
addGlobalStyle('#main_container_position { top:57px; }');
addGlobalStyle('#character_info { margin: 5px 0 0 0px; z-index:5; opacity:0.7; filter:alpha(opacity=70);}');
addGlobalStyle('#map_border_bottom_sizer { margin-top:-75px; }'); // position:absolute; width:200px; z-index:15 ; height:11px; font-size:1px; left:50%; margin-left:-100px; bottom:0px; z-index:48;//position:relative;
//addGlobalStyle('#footer_menu_left a img, #footer_menu_right a img { background:url("http://pl1.the-west.pl/images/inventory/bag.png") 40px center;}');
addGlobalStyle('#footer_menu_left, #footer_menu_right { position:absolute; z-index:5; width:auto!important; width:40px; height:40px; }');
addGlobalStyle('#menus { z-index:10; }');
addGlobalStyle('#map_border_bottom { width:98%; }');
addGlobalStyle('#wb_buy_pa, #workbar_right .workbar_top { display:none; }');
addGlobalStyle('#workbar_right.wb_premium .workbar_top { background:transparent; height:75px; }');

//addGlobalStyle('#current_task_box_text > #task_time_value { float:left; }');

//addGlobalStyle('#footer_menu_left #footer_building_gunsmith, #footer_menu_left #footer_building_tailor,#footer_menu_left #footer_building_general,#footer_menu_left #footer_building_hotel,#footer_menu_left #footer_building_bank,#footer_menu_left #footer_building_church,#footer_menu_left #footer_building_mortician ,#footer_menu_left #footer_building_cityhall,#footer_menu_left #footer_building_saloon,#footer_menu_left #footer_trader_saloon, #footer_menu_left #footer_building_market, #footer_menu_left #footer_building_sheriff { z-index:100; background-image:url('+base_img+'tw-shortcuts.png);}');

addGlobalStyle('#footer_menu_left #footer_scroll_map_to_char { background-image:url("'+base_img+'tw-shortcuts.png");}');


/***** Statystyki bitew *****/
if ( enable_westforts ) {
	var westforts_link = document.createElement("div");
	westforts_link.id = "westforts_link";
	westforts_link.innerHTML = "<a id=\"TWF_westforts_link\" href=\"http://www.westforts.com/"+ac_world+"/battles\" onClick=\"\" target=\"_blank\"></a>";
}

/***** Mapy fortów *****/
function ReplaceMap(id,content) {
	var container = document.getElementById(id);
	container.innerHTML = content;
}

if ( enable_fortsmaps ) {
	var fortsmaps_link = document.createElement('div');
	fortsmaps_link.id = 'fortsmaps_link';
	fortsmaps_link.id = 'fortsmaps_link';
	fortsmaps_link.innerHTML = '<div id="mapfort" style="" name="mapa"></div>';//position:absolute;height:200px;width:200px;border:2px solid white;top:0;left:0;
	fortsmaps_link.innerHTML += '<img class="TWF_fortsmaps" src="images/transparent.png" width="128" height="25" usemap="#map_mapy" class="TWF_fortsmaps" /><map name="map_mapy" class="TWF_fortsmaps"><area shape="rect" coords="32,0,65,25" href="javascript:ReplaceMap(\"mapfort\",\"<img src="http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/Forty/duzy.png\" />\")" alt="duży fort" title="Duży fort" class="TWF_fortsmaps" /></map>';
}
// fortsmaps_link.innerHTML += '<img class="TWF_fortsmaps" src="images/transparent.png" width="128" height="25" usemap="#map_mapy" class="TWF_fortsmaps" /><map name="map_mapy" class="TWF_fortsmaps"><area shape="rect" coords="32,0,65,25" href="javascript:ReplaceMap(\'mapfort\',\'<img src="'+base_img+'Forty/duzy.png" />\')" alt="duży fort" title="Duży fort" class="TWF_fortsmaps" /><area shape="rect" coords="65,0,94,25" href="'+base_img+'Forty/sredni.png" alt="średni fort" title="Średni fort" class="TWF_fortsmaps" /><area shape="rect" coords="94,0,120,25" href="'+base_img+'Forty/maly.png" alt="mały fort" title="Mały fort" class="TWF_fortsmaps" /></map>';

/***** New buttons *****/
var menu_settings = document.getElementById('menu_settings');
if (menu_settings) {
	if ( enable_weststats ) {
		menu_settings.parentNode.insertBefore(weststats_link, menu_settings.nextSibling);
	}
	if ( enable_fortsmaps ) {
		menu_settings.parentNode.insertBefore(fortsmaps_link, menu_settings.nextSibling);
	}
	if ( enable_westforts ) {
		menu_settings.parentNode.insertBefore(westforts_link, menu_settings.nextSibling);
	}
};

//addGlobalStyle(' {}');


// Fort Select Window
addGlobalStyle('#scroll_to_fort_list{left: 162px !important; z-index:55;}');
addGlobalStyle('#scroll_to_fort_list * { margin: 0; padding: 0; background-color:#cbb784; }');
addGlobalStyle('#scroll_to_fort_list ul li.fort_list_head { border-bottom: 1px solid #000000; background-color:#cbb784; }');
addGlobalStyle('#scroll_to_fort_list ul li { width: 142px; margin: 1px 4px; background-color:#cbb784; }');
addGlobalStyle('#scroll_to_fort_list ul li.fort_list_spacer { width: 150px; margin: 6px 0 4px 0; background-color:#cbb784; }');

(function(f){var d=document,s=d.createElement('script');s.setAttribute('type','application/javascript');s.textContent = '('+f.toString()+')()';(d.body||d.head||d.documentElement).appendChild(s);s.parentNode.removeChild(s)})(function(){

window.addEvent('domready', function(){


function ReplaceMap(id,content) {
	var container = document.getElementById(id);
	container.innerHTML = content;
}
	var el_li_fort = $('scroll_to_fort_list').getPosition();
	$('footer_fort_overview_icon').onclick = function(event){
		$('scroll_to_fort_list').addEvent('load', function() {
			console.log($('scroll_to_fort_list').getCoordinates());
		});
	};
	/* var el_li_fort = $('scroll_to_fort_list').getPosition(); 
el_li_fort.y -= 580;
$E('div', 'footer_menu_left').setStyles({'top':el_li_fort.y,'position':'absolute'});

$E('div', 'footer_menu_left').setStyle('top',wys_el_li_fort);
$E('div', 'footer_menu_left').setStyle('position','fixed');



-415px 194px */
	
	
	//top_li_fort = el_li_fort.y - 580 + 'px';
	//$E('div', 'footer_menu_left').setStyles({'top':top_li_fort,'position':'absolute'});
	//$('scroll_to_fort_list').setStyles({'position':'absolute','top':'200px'});
	
	
	//var el_okna = $('screensizer').getSize();
	//var wys_okna = el_okna.size.y;
	//var roz = 0;
	//if (wys_mapy + wys_czatu < wys_okna) {
		//var roz = wys_okna - wys_czatu;
		//var roz = wys_okna - wys_mapy;// - 103;
		//var roz = wys_czatu - 33;
		
//		Config.set("gui.chat.height",roz);
		//$('scroll_to_fort_list').setStyle('z-index', 20);
		//$('map_wrapper').setStyle('height', roz+20+'px');
		//$('map_border_bottom').setStyle('top', roz+5+'px');
		//$('map_border_bottom_sizer').setStyle('top', roz+137+'px');
		//$('footer_menu_left').setStyle('top', roz-35+'px');
		//$('footer_menu_right').setStyle('top', roz-35+'px');
		//addGlobalStyle('#screensizer {height:'+roz+'px;}');
		//}
	//alert('wysokość mapy:' +wys_mapy+ '\nwysokość czatu:' +wys_czatu+ '\nwysokość okna:' +wys_okna+ '\nróżnica:' +roz);
	
	$('right_menu').addEvents({mouseover:function(){$('right_menu').setStyles({right:'-18px',clip:'rect(auto, auto, auto, auto)'});}});
	$('right_menu').addEvents({mouseout:function(){$('right_menu').setStyles({right:'-120px',clip:'rect(auto, 25px, auto, auto)'});}});
	$('left_menu').addEvents({mouseover:function(){$('left_menu').setStyles({left:'-20px',clip:'rect(auto, auto, auto, auto)'});}});
	$('left_menu').addEvents({mouseout:function(){$('left_menu').setStyles({left:'-120px',clip:'rect(auto, auto, auto, 25px)'});}});


	// ukrywanie elementów
	var el_ukr = new Array();
	el_ukr = [$('border_cap'),$('shadow_left_top'),$('shadow_right_top'),$('shadow_left_wing'),$('shadow_right_wing'),$('shadow_left_wing_bottom'),$('shadow_right_wing_bottom'),$('head_title'),$('abdorment_left'),$('abdorment_right')];
	for (i = 0; i < el_ukr.length; i++){
		if (el_ukr.length) {
			el_ukr[i].setStyles({'display':'none'});
		}
	}
	// /ukrywanie elementów

	// usunięcie tła
//	var el_ukrt = new Array();
//	el_ukrt = [$('footer_menu_left.bottomleftcurve')];
//	for (i = 0; i < el_ukrt.length; i++){
//		if (el_ukrt.length) {
//			el_ukrt[i].setStyles({'background':''});
//		}
//	}
	// /ukrywanie tła
	//var time_job = $('task_time_value').clone();
//$('task_time_value').clone().cloneEvents('task_time_value').setStyles({'float':'right'}).injectTop('current_task_box_text');
	//$('footer_menu_left').injectTop('shadow_top');
	$('footer_menu_left').removeClass('bottomleftcurve');
	$('footer_menu_right').removeClass('bottomrightcurve');
	$('footer_menu_left').setStyles({'padding-top':'','background':'','float':'left','opacity':0.7,'left':'15px'});
	$('footer_menu_right').setStyles({'padding-top':'','background':'','float':'right','right':'15px'});
	$('minimap_container').setStyles({top:'0px!important', 'position':'relative'});
	$('left_menu').setStyles({top:'2px'});
	$('right_menu').setStyles({top:'2px'});
	$('shadow_top').setStyles({'height':'50px','z-index':'1000'});
	$('mapfort').injectTop('shadow_top');
	//$('footer_menu_left').setStyles({'background-image':'url(http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/tw-shortcuts.png)'});
	//$('footer_scroll_map_to_home_town').setStyles({'background-position':'-37px 0;'});
	//$('footer_scroll_map_to_char').setStyles({'background-position':'-37px 0;'});
	//$('footer_menu_left footer_scroll_map_to_char').setStyles({'background-image':'url("http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/tw-shortcuts.png")'});
	
	// ikonki menu
	//$('footer_scroll_map_to_char').setProperty('src', 'http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/sym1.png'); // twoja pozycja
	//$('footer_scroll_map_to_home_town').setProperty('src', 'http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/sym2.png'); // 
	//$('footer_scroll_map_to_char').setProperty('src', 'http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/sym1.png'); // 
	//$('footer_scroll_map_to_home_town').setProperty('src', 'http://pl-the-west.googlecode.com/svn/trunk/pl-the-west/images/sym2.png'); // 
	// /ikonki menu
	
	//var cre_menu = '';
	//cre_menu = '<a href="#" class="button" id="toggle"><span>Click Here</span></a>';
	//cre_menu += '<ul id="v-menu" class="v-menu">';
	//cre_menu += '<li><a href="p1.html">Technology</a></li>';
	//cre_menu += '</ul>';
	
	var cre_menu = new Element('a', {
		href: '#',
		'class': 'button',
		html: '<span>Click Here</span>',
		styles: {
			display: 'block',
			border: '1px solid white'
		}
	});
	
	//$('shadow_top').set('html', cre_menu);
	
	//function create_menu(poz, subpoz, name, src){
	//}
	//$('footer_minimap_icon').addEvents({
	//	click: function(e) {
			//$('minimap_container').setStyles({'top':'0px'});
	//		e.stop();
	//		if(e.control === true){
	//			$('minimap_container').setStyles({'top':'0px'});
	//		}
	//		console.log('Clicked!');
	//	},
	//	mouseenter: function(e) {
	//		e.stop();
	//		console.log('You are on top of me!');
	//	}
	//});
	$('footer_minimap_icon').addEvent('click', function(){ $('minimap_container').setStyles({top:'0px'}); console.log('ok'); });
	
	});
});
